import type { PiniaPlugin } from "pinia";
import { cloneDeep } from "lodash-es";

/** 重写 store 的 reset 方法，store 默认的 reset 方法只对 options api 有效，composition api 会报错*/
export const reset: PiniaPlugin = ({ store }) => {
  const initialState = cloneDeep(store.$state);
  store.$reset = () => store.$patch(cloneDeep(initialState));
};
